package data;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Calendar;

public class Util {

	protected Util() {
	}
	
	public static boolean isWeekday(Date d) {
		int day = getDayOfWeek(d);
		return day >= 2 && day <= 6;
	}
	
	/*
	 * Sunday => 1
	 * Monday => 2
	 * ...
	 * Saturday => 7
	 */
	public static int getDayOfWeek(Date d) {
		Calendar c = Calendar.getInstance();
		c.setTime(d);
		return c.get(Calendar.DAY_OF_WEEK);
	}
	
	public static Date increment(Date d) {
		Calendar c = Calendar.getInstance();
		c.setTime(d);
		c.add(Calendar.DATE, 1);
		return c.getTime();
	}
	
	public static String slot(Date d, int h) {
		SimpleDateFormat df = new SimpleDateFormat("MMM d, yyyy EEE h:mm a");
		Calendar c = Calendar.getInstance();
		c.setTime(d);
		c.set(Calendar.HOUR, h);
		c.set(Calendar.MINUTE, 0);
		String s = df.format(c.getTime());
		df = new SimpleDateFormat("h:mm a");
		c.add(Calendar.HOUR, 1);
		s += " - " + df.format(c.getTime());
		return s;
	}
}
